<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #dv {
            width: 400px;
            height: 400px;
            background: red;
            margin: auto;
        }
        #dv.hover {
            background: whitesmoke;
            border: 10px solid #000;
        }
    </style>
    <script type="text/javascript">
        window.onload = function () {
            var dv = document.getElementById("dv")
            dv.onmouseenter = function(){
                dv.className = "hover";
            }
            dv.onmouseleave = function(){
                dv.className = "";
            }
        }
    </script>
</head>
<body>
<div id="dv">移入变色</div>
</body>
</html>